#include "qwgraphicsview.h"

QWGraphicsView::QWGraphicsView(QWidget* parent):
    QGraphicsView (parent)
{

}

// 鼠标移动事件
void QWGraphicsView::mouseMoveEvent(QMouseEvent *event)
{
    QPoint point = event->pos(); // graphicsview的坐标
    emit mouseMovePoint(point);
    QGraphicsView::mouseMoveEvent(event);
}

// 鼠标按压事件
void QWGraphicsView::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton){
        QPoint point = event->pos();
        emit mouseClicked(point); // 发射信号
    }
    QGraphicsView::mousePressEvent(event);
}

// 鼠标双击事件
void QWGraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton){
        QPoint point = event->pos();
        emit mouseDoubleClick(point); // 发射信号
    }
    QGraphicsView::mouseDoubleClickEvent(event);
}

// 按键事件
void QWGraphicsView::keyPressEvent(QKeyEvent *event)
{
    emit keyPress(event);
    QGraphicsView::keyPressEvent(event);
}




